package com.project.Servlet;

import com.project.Bean.UserBean;
import com.project.Service.IUserService;
import com.project.Service.Impl.ServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.time.LocalDate;

/**
 * @Title: addServlet
 * @Package: com.project.Servlet
 * @Description:
 * @Author: Liang-Xie
 * @Date: 2022/6/21 - 11:38
 */
@SuppressWarnings("all")
public class addServlet extends HttpServlet {
    private IUserService service=new ServiceImpl();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");
        UserBean user=new UserBean();

        String username = req.getParameter("userName");
        String pwd = req.getParameter("pwd");
        user.setUsername(username);
        user.setPassword(pwd);
        service.add(user);

    }

}

